package example.designpattern.factory.simplefactory;

/**
 * 简单工厂：用于系统中确定的类
 *
 */
public class SimpleFactory {

  public MeizuPhone produce(String product) {

    if ("PRO5".equals(product)) {
      return new PRO5();
    } else if ("PRO6".equals(product)) {
      return new PRO6();
    }
    throw new IllegalArgumentException("No Such Class");
  }

}

//具体产品X2
class PRO5 implements MeizuPhone {

  @Override
  public void run() {

    System.out.println("我是一台PRO5");
  }

}

class PRO6 implements MeizuPhone {

  @Override
  public void run() {

    System.out.println("我是一台PRO6");
  }

}
